home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Graphics Plus
/
Graphics Plus.iso
/
general
/
viewers
/
polyview
/
polyvw31.lha
/
Polyview3.1
/
new
/
pvlight.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-06-23
|
5KB
|
140 lines
/*****************************************************************************
* NCSA Polyview 3.0 *
* *
* Version 3 changes and additions by Marc Andreessen. *
* Version 2 by Brian Calvert. *
* *
* Software Development Group *
* National Center for Supercomputing Applications *
* University of Illinois at Urbana-Champaign *
* *
* This is BETA release software. As such it may contain software bugs and *
* exhibit inconsistencies. *
* *
* Please send bug reports to polyview@ncsa.uiuc.edu. *
* *
* Copyright (c) 1992 The Board of Trustees of the University of Illinois. *
* *
* Permission to use, copy, and modify this software and its *
* documentation for educational, research, and non-profit purposes is *
* hereby granted, provided that the above copyright notice, the original *
* authors names, and this permission notice appear in all such copies. *
* Any distribution of this software requires the explicit and written *
* authorization of the authors. *
* *
* The University of Illinois makes no representations about the *
* suitability of this software for any purpose. It is provided "as is" *
* without warranty of any kind. *
*****************************************************************************/
/* $Header: /usr3/people/gbourhis/pv3/new/RCS/pvlight.c,v 1.1 92/09/18 10:55:26 marca Exp $ */
#ifdef RCSLOG
$Log: pvlight.c,v $
* Revision 1.1 92/09/18 10:55:26 marca
* Initial revision
*
#endif
#include "pv.h"
static float DefaultSurface[] = {
AMBIENT, 0.3, 0.3, 0.3,
DIFFUSE, 1.0, 1.0, 1.0,
SPECULAR, 0.3, 0.3, 0.3,
SHININESS, 96,
LMNULL};
static float DefaultLight[] = {
POSITION, 1.0, 0.0, 0.0, 0.0,
LCOLOR, 1.0, 1.0, 1.0,
LMNULL};
static float DefaultModel[] = {
LMNULL};
static float DefaultLightPosition[] = {
POSITION, 0.0, 0.0, 0.0, 0.0,
LMNULL};
/* The manual claims that lmdef's hold true for all windows but
lmbinds only hold true for one window. So we'll do lmbind each
time through the drawing loop for all properties :-(. */
void init_lighting (void)
{
/* Define model and material; lights will be defined each
time through the drawing loop. */
lmdef (DEFLMODEL, 1, 0, DefaultModel);
lmdef (DEFMATERIAL, 1, 0, DefaultSurface);
return;
}
void light_twoside_on (state_t *state, window_t *win)
{
WIN_LIGHT_TWOSIDE(win) = 1;
return;
}
void light_twoside_off (state_t *state, window_t *win)
{
WIN_LIGHT_TWOSIDE(win) = 0;
return;
}
void lighting_on (state_t *state, window_t *win, float x, float y, float z)
{
/* Set the new position. */
DefaultLightPosition[1] = x;
DefaultLightPosition[2] = y;
DefaultLightPosition[3] = z;
/* Def the new position. */
lmdef (DEFLIGHT, 1, 0, DefaultLightPosition);
if (WIN_LIGHT_TWOSIDE(win))
{
DefaultLightPosition[1] = -x;
DefaultLightPosition[2] = -y;
DefaultLightPosition[3] = -z;
lmdef (DEFLIGHT, 2, 0, DefaultLightPosition);
}
/* Bind the material to turn everything on. */
/* Bind lighting model and light also, so lighting will
work across multiple windows. */
lmbind (MATERIAL, 1);
lmbind (LMODEL, 1);
lmbind (LIGHT0, 1);
/* If twosided lighting is enabled, bind the other light,
else turn it off (in case it was bound earlier). */
if (WIN_LIGHT_TWOSIDE(win))
lmbind (LIGHT1, 2);
else
lmbind (LIGHT1, 0);
/* Switch lmcolor modes. */
lmcolor (LMC_AD);
return;
}
void lighting_off (void)
{
/* Go back to unlit mode. Unbinding material is enough
to turn everything off. */
lmbind (MATERIAL, 0);
/* Go back to cpack's affecting color. */
lmcolor (LMC_COLOR);
return;
}